package no.ffi.gismoidm.attrex;

import java.util.Properties;

/**
 *
 * @author anders
 */
public class Startstring extends BooleanOperator {
    
    private StringOperand op1, op2;

    public Startstring(StringOperand op1, StringOperand op2) { 
        this.op1 = op1;
        this.op2 = op2;
    }
    
    // Utility method for short hand use
    public Startstring(String s1, String s2) {
        this(new AttributeOperand(s1),new StringOperand(s2));
    }

    
    @Override
    public BooleanValue getBooleanValue(Properties attributes) throws AttributeEvaluationException {
        String s1 = op1.getStringValue(attributes).toString();
        String s2 = op2.getStringValue(attributes).toString();
        return new BooleanValue(s1.startsWith(s2));
    }

    public String toString() {
        return "startswith(" + op1.toString() + "," + op2.toString() + ")";
    }
    
}
